package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchMonitoringData;
import com.ruoyi.system.service.IDispatchMonitoringDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监测数据Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchMonitoringData")
public class DispatchMonitoringDataController extends BaseController
{
    @Autowired
    private IDispatchMonitoringDataService dispatchMonitoringDataService;

    /**
     * 查询监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMonitoringData:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchMonitoringData dispatchMonitoringData)
    {
        startPage();
        List<DispatchMonitoringData> list = dispatchMonitoringDataService.selectDispatchMonitoringDataList(dispatchMonitoringData);
        return getDataTable(list);
    }

    /**
     * 导出监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMonitoringData:export')")
    @Log(title = "监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchMonitoringData dispatchMonitoringData)
    {
        List<DispatchMonitoringData> list = dispatchMonitoringDataService.selectDispatchMonitoringDataList(dispatchMonitoringData);
        ExcelUtil<DispatchMonitoringData> util = new ExcelUtil<DispatchMonitoringData>(DispatchMonitoringData.class);
        util.exportExcel(response, list, "监测数据数据");
    }

    /**
     * 获取监测数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMonitoringData:query')")
    @GetMapping(value = "/{monitoringDataId}")
    public AjaxResult getInfo(@PathVariable("monitoringDataId") Long monitoringDataId)
    {
        return success(dispatchMonitoringDataService.selectDispatchMonitoringDataByMonitoringDataId(monitoringDataId));
    }

    /**
     * 新增监测数据
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMonitoringData:add')")
    @Log(title = "监测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchMonitoringData dispatchMonitoringData)
    {
        return toAjax(dispatchMonitoringDataService.insertDispatchMonitoringData(dispatchMonitoringData));
    }

    /**
     * 修改监测数据
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMonitoringData:edit')")
    @Log(title = "监测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchMonitoringData dispatchMonitoringData)
    {
        return toAjax(dispatchMonitoringDataService.updateDispatchMonitoringData(dispatchMonitoringData));
    }

    /**
     * 删除监测数据
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMonitoringData:remove')")
    @Log(title = "监测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{monitoringDataIds}")
    public AjaxResult remove(@PathVariable Long[] monitoringDataIds)
    {
        return toAjax(dispatchMonitoringDataService.deleteDispatchMonitoringDataByMonitoringDataIds(monitoringDataIds));
    }
}
